package com.example.sunran;

import com.example.sunran.servlet.DownloadFileServlet;
import com.example.sunran.servlet.GetFileListServlet;
import com.example.sunran.servlet.UploadFileServlet;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.webapp.WebAppContext;

public class App {
    private static  final   String DEFAULT_WEBAPP_PATH = "./src/main/resources/";
    public static void main(String[] args) throws Exception {

        Server server = new Server(8080);

        ServletHandler  handler = new ServletHandler();
        server.setHandler(handler);

        WebAppContext webAppContext = new WebAppContext(DEFAULT_WEBAPP_PATH,"/");
        webAppContext.addServlet(UploadFileServlet.class,"/upload");
        webAppContext.addServlet(GetFileListServlet.class,"/getlist");
        webAppContext.addServlet(DownloadFileServlet.class,"/download");
        server.setHandler(webAppContext);
        server.start();
        server.join();
    }
}
